# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Jeff Bilyk <jbilyk@gmail.com>
# Contributor: Jean-Charles de Longueville <jch@hellea.eu>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=x2goserver
pkgver=4.1.0.6
pkgrel=0
pkgdesc="X2Go enables you to access a graphical desktop of a computer over a low bandwidth (or high bandwidth) connection"
options="suid !check" # No option to run testsuite in make
url="https://wiki.x2go.org/doku.php"
# riscv64 blocked by nx-libs
arch="all !riscv64"
license="GPL-2.0-or-later"
depends="perl perl-config-simple perl-dbi perl-file-readbackwards
	perl-capture-tiny perl-dbd-sqlite bash iproute2 makepasswd
	openssh lsof xauth perl-file-basedir mcookie nx-libs perl-file-which
	perl-try-tiny perl-switch"
makedepends="libssh2-dev mandoc"
install="$pkgname.pre-install $pkgname.post-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://code.x2go.org/releases/source/x2goserver/x2goserver-$pkgver.tar.gz
	$pkgname.initd
	xsession-alpine-support.patch
	makefile.patch
	"
pkgusers="x2gouser"
pkggroups="x2gouser"

prepare() {
	default_prepare
	local dir
	for dir in x2goserver*; do
		if [ -d $dir ]; then
			sed -i -e "s/^build-indep:.*/build-indep: /g" $dir/Makefile
		fi
	done
}

build() {
	make PREFIX=/usr
}

package() {
	make DESTDIR="$pkgdir" PREFIX=/usr install
	install -Dm 755 "$srcdir/$pkgname.initd" "$pkgdir/etc/init.d/$pkgname"
}

sha512sums="
3c82ae5bd86dd938bedc70aa01d2d9123d749a36396f44100a7a94e58e5dba2d347fc967691fe0978b55e42b7fb90ddd065eafaba88dc6faee83c14645447e1b  x2goserver-4.1.0.6.tar.gz
1784894c3f04abbb626bf8178dc6c8383a0d2883eb168cb805e707581d547584ac8eb767155153ee7d50d2192b757fa8c71e40fa9393c8df39e3cda94e05b7b4  x2goserver.initd
ce5248dc10ffe6eaf22bab723590c475d5954af48d5022991398acb32c015aaa086ae02779d812610efde73b20d80bdc41b156a3283471048a610a92f1ba4217  xsession-alpine-support.patch
6f3f893b38d33548bd4963720b7e61b924a64f6da36b76c5ffe5f8eb011decd2d9215fc235704f0e047cbaaaaaee662e65289a7d229d9a43712ab5ce35866e74  makefile.patch
"
